package com.probox.wechat.api.factory;

import com.probox.common.core.domain.R;
import com.probox.wechat.api.RemoteWechatService;
import com.probox.wechat.api.domain.WechatAuthorizationInfoVo;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteWechatFallbackFactory implements FallbackFactory<RemoteWechatService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteWechatFallbackFactory.class);

    @Override
    public RemoteWechatService create(Throwable throwable) {
        log.error("调用远程微信服务错误...",throwable);
        return new RemoteWechatService() {

            @Override
            public R<WechatAuthorizationInfoVo> getAuthorizationInfo(String authorizerAppid) {
                return R.fail("查询appid:{"+authorizerAppid+"}授权信息调用失败");
            }
        };
    }
}
